<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateStoreCouponIssueTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('store_coupon_issues', function (Blueprint $table) {
            $table->id()->comment('优惠券前台领取表');
            $table->string('product_id')->nullable()->index()->comment('所属商品id');
            $table->string('cid')->nullable()->index()->comment('优惠券id');
            $table->integer('category_id')->nullable()->index()->comment('分类id');
            $table->integer('total_count')->nullable()->comment('优惠劵领取数量');
            $table->integer('remain_count')->nullable()->comment('优惠劵剩余领取数量');
            $table->decimal('full_reduction',8,2)->nullable()->comment('消费满多少赠送优惠券');
            $table->string('title')->comment('优惠劵名称');
            $table->integer('integral')->nullable()->comment('兑换消耗积分值');
            $table->decimal('coupon_price',10,2)->nullable()->comment('兑换的优惠劵面值');
            $table->decimal('use_min_price')->nullable()->comment('最低消费多少金额可用优惠劵');
            $table->integer('coupon_time')->nullable()->comment('优惠劵有效期限(单位：天)');
            $table->tinyInteger('status')->default(1)->comment('状态:1正常(默认) 0未开启');
            $table->tinyInteger('is_full_give')->default(1)->comment('是否满赠0-否 1-是(默认)');
            $table->tinyInteger('is_give_subscribe')->default(0)->comment('是否首次关注赠送 0-否 1-是(默认)');
            $table->tinyInteger('is_permanent')->default(0)->comment('是否无限张数: 1限量 0无限(默认)');
            $table->tinyInteger('limitquantity')->nullable()->comment('发布限制数量');
            $table->tinyInteger('system_admin_id')->comment('添加的管理员的id');
            $table->string('type',16)->default('receives_one')->comment('优惠券类型 receives_one-通用券 receives_two-品类券 receives_three-商品券');
            $table->string('receive_type',16)->default('receive_one')->comment('领取方式 receive_one 手动领取，receive_two 新人券，receive_three赠送券，receive_four会员券');
            $table->timestamp('start_use_time')->nullable()->comment('优惠券使用开始时间');
            $table->timestamp('end_use_time')->nullable()->comment('优惠券使用结束时间');
            $table->integer('sort')->default(0)->comment('排序');
            $table->timestamp('start_time')->nullable()->comment('优惠劵领取开始时间');
            $table->timestamp('end_time')->nullable()->comment('优惠劵领取结束时间');
            $table->softDeletes();
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('store_coupon_issue');
    }
}
